<script setup lang="ts">

const option=ref<ECOption>({
  title: {
    text: '订单信息统计',
    subtext: '支付状态信息',
    left: 'center'
  },
  tooltip: {
    trigger: 'item'
  },
  legend: {
    orient: 'vertical',
    left: 'left'
  },
  series: [
    {
      name: '数量：（个）',
      type: 'pie',
      radius: '50%',
      data: [
        { value: 0, name: '正在生成' },
        { value: 0, name: '未支付' },
        { value: 0, name: '已支付' },
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
})
onMounted(function (){
  cFetch<any[]>('/statistics/order',{
    auth:true,
    defaultOpts:{
      method:"GET",
    }
  }).then(res=>{
    if(res.code===200){
      let data=res.data
      let obj:any={}
      obj[data[0].status]=data[0].amount
      obj[data[1].status]=data[1].amount
      obj[data[2].status]=data[2].amount

      option.value.series[0].data[0].value=obj[0]
      option.value.series[0].data[1].value=obj[1]
      option.value.series[0].data[2].value=obj[2]

      // console.log(obj)
    }
  })
})

</script>

<template>
  <VChart :option="option"/>
</template>

<style scoped lang="scss">

</style>